#ifndef __DEFINES_H__
#define __DEFINES_H__

#ifdef __NEED_DEBUG__
  #include <stdio.h>
  #define app_debug(format, ...) do { \
    fprintf(stderr, "%s:%s():%d -> " format "\n", __FILE__, __func__, __LINE__,\
                      __VA_ARGS__ ); \
  } while(0)
#else
  #define app_debug(...) /* __VA_ARGS__ */;
#endif

/*For IoOps.cpp*/
#define XP_IOPS_READ        1<<0
#define XP_IOPS_WRITE       1<<1
#define XP_IOPS_ERROR       1<<2
#define XP_IOPS_CONNECTING  1<<3
#define XP_IOPS_CONNECTED   1<<4
#define XP_IOPS_OK          1<<5
#define XP_IOPS_EOF         1<<6
#define XP_IOPS_ALERT       1<<7

#define BIT_SET(var,bit)    var |= (bit)
#define BIT_UNSET(var,bit)  var &= ~(bit)

#define XP_XMPP_READ_BUF_MAX 2048
#define XP_XMPP_WRITE_BUF_MAX 5120
#define XP_XMPP_STAT_BUF_MAX 512
#define XP_XMPP_HB_BUF_MAX XP_XMPP_WRITE_BUF_MAX
#define XP_XMPP_TO_JID_MAX XP_XMPP_STAT_BUF_MAX
#define XP_IQ_INBOUND_REGISTRATION_ID "cpp-autoregister"
#define XP_IQ_INBOUND_REGISTRATION_XMLNS "jabber:iq:register"
#define XP_IQ_SESSION_ID "cpp-pa-auth"
#define XP_IQ_MUC_ID "cpp-pa-muc"
#define XP_IQ_MUC_JOIN "cpp-pa-muc-join"

typedef unsigned int ioevent;
typedef ioevent iostat;

typedef enum xret {
  xp_OK = 0,
  xp_FAIL,
  xp_EOF,
  xp_CONNECTING,
  xp_CONNECTED,
  xp_EPARAM,
  xp_ENOMEM,
  xp_EDENY,
  xp_ENOTFOUND,
  xp_EAGAIN,
  xp_ESYS,
  xp_TIMEOUT,
} xret;

#endif

/*
vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=2:encoding=utf-8:textwidth=80
*/
